#ifndef CONFIGDATA_H
#define CONFIGDATA_H

/**
 * @brief 导航栏树索引
 * 
 * 表示导航栏树的索引，用于在导航栏树中查找节点。
 */
enum NavTreeIndex {
    Config_1 = 10,
    Main_1 = 11,
    Trace_1 = 12,

    Config_2 = 20,
    Main_2 = 21,
    Trace_2 = 22,

    Config_3 = 30,
    Main_3 = 31,
    Trace_3 = 32,

    Config_4 = 40,
    Main_4 = 41,
    Trace_4 = 42,

    Config_5 = 50,
    Main_5 = 51,
    Trace_5 = 52,

    Config_6 = 60,
    Main_6 = 61,
    Trace_6 = 62,
};

/**
 * @brief 工况类配置数据结构
 * 
 * 包含铁水成分、目标成分、废钢成分和溜槽流量等参数
 */
struct ConfigWorkingConditionData {
    
    // 铁水成分 (Molten Iron Composition)
    struct MoltenIronComposition {
        double Mn = 0.0;        // 铁水Mn (%)
        double P = 0.0;         // 铁水P (%)
        double S = 0.0;         // 铁水S (%)
        double Ti = 0.0;        // 铁水Ti (%)
        double other = 0.0;     // 铁水其他 (%)
    } moltenIron;
    
    // 目标成分 (Target Composition)
    struct TargetComposition {
        double C = 0.0;         // 目标C (%)
        double Si = 0.0;        // 目标Si (%)
        double Mn = 0.0;        // 目标Mn (%)
        double P = 0.0;         // 目标P (%)
        double S = 0.0;         // 目标S (%)
        double T = 0.0;         // 目标T (℃)
    } target;
    
    // 废钢成分 (Scrap Steel Composition)
    struct ScrapSteelComposition {
        double C = 0.0;         // 废钢C (%)
        double Si = 0.0;        // 废钢Si (%)
        double Mn = 0.0;        // 废钢Mn (%)
        double oxidation = 0.0; // 铁氧化 (%)
    } scrapSteel;
    
    // 溜槽流量 (Chute Flow Rate)
    struct ChuteFlowRate {
        double normal = 0.0;    // 正常溜滑 (t/min)
        double retain = 0.0;    // 留渣量 (t)
        double total = 0.0;     // 全留 (t)
        double more = 0.0;      // 多留 (t)
        double less = 0.0;      // 少留 (t)
        double none = 0.0;      // 不留 (t)
    } chuteFlow;
};

/**
 * @brief 氧枪类配置数据结构
 * 
 * 包含氧枪划分、真实氧流量、烧结矿品位、提供氧量、调整铁水C上限等参数
 */
struct ConfigOxygenLanceData {
    
    double lanceDivision[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
    
    // 后吹氧利用率 (Post-Blow Oxygen Utilization Rate)
    double postBlowOxygenUtilization = 0.0;     // (%)
    
    // 初始样氧因子 (Initial Sample Oxygen Factor)
    struct InitialOxygenFactor {
        double A = 0.0;         // 初始样氧因子A
        double B = 0.0;         // 初始样氧因子B
    } initialOxygenFactor;
    
    // 真实氧流量 (Actual Oxygen Flow Rate)
    double actualOxygenFlow = 0.0;              // (m³/min)
    
    // 烧结矿品位 (Sintered Ore Grade)
    double sinteredOreGrade = 0.0;              // (%)
    
    // 焦丁中碳含量 (Coke Breeze Carbon Content)
    double cokeBreezeCarbonContent = 0.0;       // (%)
    
    // 石灰石CO2含量 (Limestone CO2 Content)
    double limestoneCO2Content = 0.0;           // (%)
    
    // 提供氧量 (Oxygen Supply)
    struct OxygenSupply {
        double sinter = 0.0;    // 烧结 (m³)
        double steel = 0.0;     // 钢渣 (m³)
        double coke = 0.0;      // 焦丁 (m³)
        double limestone = 0.0; // 石灰石 (m³)
    } oxygenSupply;
    
    // 调整铁水C上限 (Adjust Molten Iron C Upper Limit)
    double adjustMoltenIronCUpperLimit = 0.0;   // (%)
    
    // 调节比例 (Adjustment Ratio)
    double adjustmentRatio = 0.0;               // (%)
};

/**
 * @brief 物料类配置数据结构
 * 
 * 包含投料模式选择、保留矿型等参数
 */
struct ConfigMaterialData {
    
    // 投料模式选择 (Material Feeding Mode Selection)
    struct FeedingMode {
        int mode = 0;           // 模式编号 (0, 1, 2, ...)
        double csjk = 0.0;      // csjk参数
        double gsjk = 0.0;      // gsjk参数
    } feedingMode;
};

constexpr int MAIN_PAGE_WORKING_MAX_ITEMS = 16;
constexpr int MAIN_PAGE_MATERIAL_MAX_ITEMS = 20;
constexpr int MAIN_PAGE_CHART_TABLE_ROWS = 2;
constexpr int MAIN_PAGE_CHART_TABLE_COLUMNS = 7;
constexpr int MAIN_PAGE_OPER_STAGE_ROWS = 3;
constexpr int MAIN_PAGE_OPER_STAGE_COLUMNS = 7;
constexpr int MAIN_PAGE_OPER_TOTAL_ROWS = 3;
constexpr int MAIN_PAGE_OPER_TOTAL_COLUMNS = 7;
constexpr int MAIN_PAGE_PROCESS_STAGE_COUNT = 9;
constexpr int MAIN_PAGE_VIDEO_STATUS_MAX = 64;
constexpr int MAIN_PAGE_VIDEO_SUGGESTION_MAX = 256;

enum MainPageProcessStage {
    ProcessStage_SmeltingStart = 0,
    ProcessStage_AddScrapSteel,
    ProcessStage_PourMoltenIron,
    ProcessStage_BlowingStart,
    ProcessStage_BlowingEnd,
    ProcessStage_TappingSteel,
    ProcessStage_SlagSplashing,
    ProcessStage_SlagRemoval,
    ProcessStage_SmeltingEnd
};

struct MainPageKVItem {
    char name[64] = {0};
    char value[64] = {0};
};

struct MainPageWorkingConditionData {
    int count = 0;
    MainPageKVItem items[MAIN_PAGE_WORKING_MAX_ITEMS];
};

struct MainPageMaterialData {
    int count = 0;
    MainPageKVItem items[MAIN_PAGE_MATERIAL_MAX_ITEMS];
};

struct MainPageOxygenLanceData {
    double oxygenFlow = 0.0;          // 氧气流量
    double lanceHeight = 0.0;         // 氧枪高度
    double readingBlowQuantity = 0.0; // 读数吹氧量
    double accumulatedBlowQuantity = 0.0; // 累计吹氧量
    double converterAngle = 0.0;      // 转炉角度
    double oxygenPressure = 0.0;      // 氧气压力
};

struct MainPageBlowingData {
    char currentBlowingTime[64] = {0};
    char estimatedRemainingTime[64] = {0};
    char currentTemperature[64] = {0};
    char currentCarbonContent[64] = {0};
    char operatingMode[64] = {0};
};

constexpr int MAIN_PAGE_CHART_MAX_POINTS = 128;

struct MainPageChartPoint {
    double x = 0.0;
    double y = 0.0;
};

struct MainPageChartSeriesData {
    int count = 0;
    MainPageChartPoint points[MAIN_PAGE_CHART_MAX_POINTS];
};

struct MainPageChartTableData {
    char items[MAIN_PAGE_CHART_TABLE_ROWS][MAIN_PAGE_CHART_TABLE_COLUMNS][64] = {{{0}}};
};

struct MainPageOperStageData {
    char stageItems[MAIN_PAGE_OPER_STAGE_ROWS][MAIN_PAGE_OPER_STAGE_COLUMNS][64] = {{{0}}};
};

struct MainPageOperTotalData {
    char totalItems[MAIN_PAGE_OPER_TOTAL_ROWS][MAIN_PAGE_OPER_TOTAL_COLUMNS][64] = {{{0}}};
};

struct MainPageProcessData {
    int currentStage = 0;
    char currentTime[64] = {0};
    bool stageCompleted[MAIN_PAGE_PROCESS_STAGE_COUNT] = {false};
};

struct MainPageVideoData {
    char status[MAIN_PAGE_VIDEO_STATUS_MAX] = {0};
    char suggestion[MAIN_PAGE_VIDEO_SUGGESTION_MAX] = {0};
    bool abnormal = false;
};

struct MainPageChartData {
    MainPageChartSeriesData actualLanceSeries;    // 实际枪位
    MainPageChartSeriesData standardLanceSeries;  // 标准枪位
    MainPageChartSeriesData oxygenFlowSeries;     // 氧气流量
    MainPageChartSeriesData limeClassSeries;      // 石灰类
    MainPageChartSeriesData rawWhiteClassSeries;  // 生白类
    MainPageChartSeriesData ironOreClassSeries;   // 铁矿石类
    MainPageChartTableData tableData;             // 枪位表格
};

#endif // CONFIGDATA_H